package cn.wen.eeayjoke;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.util.Arrays;

import butterknife.BindView;
import cn.wen.base.adapter.recyclerview.QuickRecyclerAdapter;
import cn.wen.base.adapter.recyclerview.QuickRecyclerViewHolder;
import cn.wen.base.decoration.LinearItemDecoration;
import cn.wen.core.ui.AppFragment;
import cn.wen.eeayjoke.ui.BuglyTestActivity;
import cn.wen.eeayjoke.ui.LoadingTestActivity;
import cn.wen.eeayjoke.ui.NetTestActivity;
import cn.wen.eeayjoke.ui.PayTestActivity;
import cn.wen.eeayjoke.ui.PullZoomTestActivity;
import cn.wen.eeayjoke.ui.RefreshTestActivity;
import cn.wen.eeayjoke.ui.SelectedImageTestActivity;
import cn.wen.eeayjoke.ui.ShareTestActivity;
import cn.wen.eeayjoke.ui.WebTestActivity;
import cn.wen.eeayjoke.ui.XImageViewTestActivity;
import cn.wen.eeayjoke.ui.ZxingTestActivity;

/**
 * 测试主页面
 */
public class MainFmt extends AppFragment {

    @BindView(R.id.recycler_view)
    RecyclerView mRecyclerView;
    private Class[] mActivities = new Class[]{
            SelectedImageTestActivity.class,
            ZxingTestActivity.class,
            RefreshTestActivity.class,
            ShareTestActivity.class,
            WebTestActivity.class,
            LoadingTestActivity.class,
            XImageViewTestActivity.class,
            BuglyTestActivity.class,
            NetTestActivity.class,
            PayTestActivity.class,
            PullZoomTestActivity.class
    };
    private QuickRecyclerAdapter<Class> mAdapter;

    @Override
    public Object getContentLayout() {
        return R.layout.activity_main;
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        // 取消侧划返回
    }

    @Override
    public void initView(View contentView) {
        mAdapter = new QuickRecyclerAdapter<Class>(getAppActivity(), Arrays.asList(mActivities), R.layout.item_main_test) {
            @Override
            protected void convert(QuickRecyclerViewHolder holder, final Class item, int position) {
                holder.setText(R.id.tv, item.getSimpleName());
                holder.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        startActivity(item);
                    }
                });
            }
        };
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getAppActivity()));
        // 添加分割线
        mRecyclerView.addItemDecoration(new LinearItemDecoration(getAppActivity()));
        mRecyclerView.setAdapter(mAdapter);
    }




}
